count=Hash.new(0)
File.open("words.txt") do |f|
    f.each_line do |line|
        words=line.split
        words.each do |word|
            count[word]+=1
        end
    end
end

count.sort{|a,b|
    a[1]<=>b[1]
}.each do |key,value|
    print "#{key}:#{value}\n"
end